package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.mvp.model.UserModel
import com.baizan.daka.mvp.model.bean.PakeageInfoBean
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast
import com.baizan.daka.ui.contract.MyPackageContract

class MyPackagePresenter(val mView: MyPackageContract.View) : BasePresenter(),
    MyPackageContract.Presenter {

    val userModel: UserModel by lazy { UserModel() }

    override fun loadMyVipList(pageNo:Int,usedFlag: Int? ) {
        mView.showLoadingDialog()
        userModel.getVipList(pageNo, usedFlag)
            .subscribe(object :CommonSubscriber<BasePageResponse<PakeageInfoBean>>(compositeDisposable){
                override fun onCallNext(t: BasePageResponse<PakeageInfoBean>?) {
                    mView.loadMyVipList(t!!)
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                    mView.hideLoadingDialog()
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    showToast(e)
                }
            })
    }


}

